﻿function focus_input(el) 
{ 
   // el.className = (el.className == "cssTextBox") ? "cssTextBox" : ""; 
}
function blur_input(el) 
{ 
   // el.className = (el.className == "cssTextBox") ? "cssTextBox" : ""; 
}
/*GridView*/
var oldgridSelectedColor
function setMouseOverColor(element)
{
    oldgridSelectedColor    = element.className;
    element.className       = 'cssSelectedRow';
}

function setMouseOutColor(element)
{
    element.className = oldgridSelectedColor;
}
function setMouseOverColor2(element)
{
    oldgridSelectedColor    = element.className;
    element.className       = 'cssSelectedRow2';
}

function setMouseOutColor2(element)
{
    element.className = oldgridSelectedColor;
}
//-------------------------------------------------------
//this is to select or unselect the datagrid check boxes 
function DGSelectOrUnselectAll(grdid,obj,objlist){ 
//this function decides whether to check or uncheck all

    if(obj.checked) 
        DGSelectAll(grdid,objlist,1) 
    else 
        DGSelectAll(grdid,objlist,0) 
} 
//----------  
function DGSelectAll(grdid,objid,check){ 
//.this function is to check all the items

    var chkbox; 
    var i=2; 
    if(i <10 )
    {
       chkbox=document.getElementById(grdid + '_ctl0' + i + '_' + objid); 
    }
    else
    {
        chkbox=document.getElementById(grdid + '_ctl' + i + '_' + objid); 
    }   
    while(chkbox!=null){ 
        if(check ==1)
        {
            chkbox.checked = true; 
        }
        else
        {
            chkbox.checked = false; 
        }
        i=i+1; 
        if(i < 10 )
        {
           chkbox=document.getElementById(grdid + '_ctl0' + i + '_' + objid); 
        }
        else
        {
            chkbox=document.getElementById(grdid + '_ctl' + i + '_' + objid); 
        }        
    } 
}
function DGCheckOne(grdid,obj,objlist){ 
    var chkbox; 
    var i=2; 
    if(i < 10 )
    {
       chkbox=document.getElementById(grdid + '_ctl0' + i + '_' + objlist); 
    }
    else
    {
        chkbox=document.getElementById(grdid + '_ctl' + i + '_' + objlist); 
    }    
    while(chkbox!=null)
    { 
        chkbox.checked = false; 
        i=i+1; 
        if(i < 10 )
        {
           chkbox=document.getElementById(grdid + '_ctl0' + i + '_' + objlist); 
        }
        else
        {
            chkbox=document.getElementById(grdid + '_ctl' + i + '_' + objlist); 
        }     
    } 
    obj.checked = true; 
}
/*End GridView*/

/*End DataList*/
//-------------------------------------------------------
 
function DLSelectOrUnselectAll1(grdid,obj,objlist){ 
//this function decides whether to check or uncheck all

    if(obj.checked) 
        DLSelectAll1(grdid,objlist,1) 
    else 
        DLSelectAll1(grdid,objlist,0) 
} 
//----------  
function DLSelectAll1(grdid,objid,check){ 
//.this function is to check all the items

    var chkbox; 
    var i=1; 
    if(i <10 )
    {
       chkbox=document.getElementById(grdid + '_ctl0' + i + '_' + objid); 
    }
    else
    {
        chkbox=document.getElementById(grdid + '_ctl' + i + '_' + objid); 
    }   
    while(chkbox!=null){ 
        if(check ==1)
        {
            chkbox.checked = true; 
        }
        else
        {
            chkbox.checked = false; 
        }
        i=i+2; 
        if(i < 10 )
        {
           chkbox=document.getElementById(grdid + '_ctl0' + i + '_' + objid); 
        }
        else
        {
            chkbox=document.getElementById(grdid + '_ctl' + i + '_' + objid); 
        }        
    } 
}
function DLSelectOrUnselectAll2(grdid,obj,objlist){ 
//this function decides whether to check or uncheck all

    if(obj.checked) 
        DLSelectAll2(grdid,objlist,1) 
    else 
        DLSelectAll2(grdid,objlist,0) 
} 
//----------  
function DLSelectAll2(grdid,objid,check){ 
//.this function is to check all the items

    var chkbox; 
    var i=2; 
    if(i <10 )
    {
       chkbox=document.getElementById(grdid + '_ctl0' + i + '_' + objid); 
    }
    else
    {
        chkbox=document.getElementById(grdid + '_ctl' + i + '_' + objid); 
    }   
    while(chkbox!=null){ 
        if(check ==1)
        {
            chkbox.checked = true; 
        }
        else
        {
            chkbox.checked = false; 
        }
        i=i+2; 
        if(i < 10 )
        {
           chkbox=document.getElementById(grdid + '_ctl0' + i + '_' + objid); 
        }
        else
        {
            chkbox=document.getElementById(grdid + '_ctl' + i + '_' + objid); 
        }        
    } 
}
/*End GridView*/

/*Grid Role*/
function DGSelectOrUnselectRoleAll(grdid,obj){ 
//this function decides whether to check or uncheck all

    if(obj.checked) 
        DGSelectRoleAll(grdid,1) 
    else 
        DGSelectRoleAll(grdid,0) 
} 
//----------  
function DGSelectRoleAll(grdid,check){ 
//.this function is to check all the items

    var chkbox1,chkbox2,chkbox3,chkbox4,chkbox5; 
    var i=2; 
    cbxReadAll=document.getElementById(grdid + '_' + 'cbxReadAll');
    cbWriteAll=document.getElementById(grdid + '_' + 'cbWriteAll');
    cbDeleteAll=document.getElementById(grdid + '_' + 'cbDeleteAll');
    cbUpdateAll=document.getElementById(grdid + '_' + 'cbUpdateAll');
    if(check ==1)
    {
        cbxReadAll.checked=true; 
        cbDeleteAll.checked=true;
        cbWriteAll.checked=true;
        cbUpdateAll.checked=true;
    }       
    else
    {
        cbxReadAll.checked=false; 
        cbDeleteAll.checked=false;
        cbWriteAll.checked=false;
        cbUpdateAll.checked=false;
    }
    if(i <10 )
    {
        chkbox1=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbSelect');
        chkbox2=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbRead'); 
        chkbox3=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbUpdate'); 
        chkbox4=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbWrite'); 
        chkbox5=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbDelete'); 
    }
    else
    {        
        chkbox1=document.getElementById(grdid + '_ctl' + i + '_' + 'cbSelect');
        chkbox2=document.getElementById(grdid + '_ctl' + i + '_' + 'cbRead'); 
        chkbox3=document.getElementById(grdid + '_ctl' + i + '_' + 'cbUpdate'); 
        chkbox4=document.getElementById(grdid + '_ctl' + i + '_' + 'cbWrite'); 
        chkbox5=document.getElementById(grdid + '_ctl' + i + '_' + 'cbDelete'); 
    }   
    while(chkbox1!=null){ 
        if(check ==1)
        {
            chkbox1.checked=true; 
            chkbox2.checked=true; 
            chkbox3.checked=true; 
            chkbox4.checked=true; 
            chkbox5.checked=true; 
        }
        else
        {
            chkbox1.checked=false; 
            chkbox2.checked=false; 
            chkbox3.checked=false; 
            chkbox4.checked=false; 
            chkbox5.checked=false; 
        }
        i=i+1; 
        if(i < 10 )
        {           
            chkbox1=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbSelect');
            chkbox2=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbRead'); 
            chkbox3=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbUpdate'); 
            chkbox4=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbWrite'); 
            chkbox5=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbDelete');  
        }
        else
        {
            chkbox1=document.getElementById(grdid + '_ctl' + i + '_' + 'cbSelect');
            chkbox2=document.getElementById(grdid + '_ctl' + i + '_' + 'cbRead'); 
            chkbox3=document.getElementById(grdid + '_ctl' + i + '_' + 'cbUpdate'); 
            chkbox4=document.getElementById(grdid + '_ctl' + i + '_' + 'cbWrite'); 
            chkbox5=document.getElementById(grdid + '_ctl' + i + '_' + 'cbDelete'); 
        }        
    } 
}
function DGSelectRoleOne(grdid,obj,i){ 
//.this function is to check all the items

    
    var chkbox2,chkbox3,chkbox4,chkbox5; 
    i=i+1; 
    if(i < 10 )
    {           
        chkbox2=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbRead'); 
        chkbox3=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbUpdate'); 
        chkbox4=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbWrite'); 
        chkbox5=document.getElementById(grdid + '_ctl0' + i + '_' + 'cbDelete');  
    }
    else
    {
        chkbox2=document.getElementById(grdid + '_ctl' + i + '_' + 'cbRead'); 
        chkbox3=document.getElementById(grdid + '_ctl' + i + '_' + 'cbUpdate'); 
        chkbox4=document.getElementById(grdid + '_ctl' + i + '_' + 'cbWrite'); 
        chkbox5=document.getElementById(grdid + '_ctl' + i + '_' + 'cbDelete'); 
    } 
    if(obj.checked) 
    {
        chkbox2.checked=true; 
        chkbox3.checked=true; 
        chkbox4.checked=true; 
        chkbox5.checked=true; 
    }
    else
    {
        chkbox2.checked=false; 
        chkbox3.checked=false; 
        chkbox4.checked=false; 
        chkbox5.checked=false; 
    } 
}

/*End Grid Role*/
function ToggleInput(check, txtBox) {
   // alert(check.checked + txtBox);
   document.getElementById(txtBox).disabled = !(check.checked)
   
}
function ToggleInputSet(check, txtBox)
{
   document.getElementById(txtBox).disabled = !(check.checked);
   document.getElementById(txtBox).value = "";
   //alert(document.getElementById(txtBox).value);
}
function DropdownlistInput(valueDrop, txtBox)
{
    if(valueDrop == 0 || valueDrop == 1 )
    {
        document.getElementById(txtBox).disabled = true;
    }
    else
    {
        document.getElementById(txtBox).disabled = false;       
    }  
}


